# -*- coding: utf-8 -*-
__author__ = 'hftec'
import random
from lcopa import load_uphi_data,calculate_codev

class LcopaScan:
    def __init__(self,file_name):
        self.file_name = file_name
        self.dec = 2000.0
        self.inc = 2000.0
    def ramdom_scan(self,posi_max,neg_max):
        #while(True):
        phi =  random.uniform(neg_max, posi_max)
        u_phi = load_uphi_data.U_PHI
        u_phi.load_uphi(self.file_name)
        calculate_codev.calculate_voltage(float(phi))
        print "phi:",phi
    def inc_scan(self,posi_max,neg_max,step):
        self.inc = neg_max
        u_phi = load_uphi_data.U_PHI
        u_phi.load_uphi(self.file_name)
        while(self.inc <= posi_max):
            #phi =  random.uniform(0, 2000)
            #calculate_codev.calculate_voltage(float(self.inc))
            print "phi:",self.inc
            self.inc += step
    def dec_scan(self,posi_max,neg_max,step):
        self.dec = posi_max
        u_phi = load_uphi_data.U_PHI
        u_phi.load_uphi(self.file_name)
        while(self.dec >= neg_max):
            #calculate_codev.calculate_voltage(float(self.dec))
            print "phi:",self.dec
            self.dec -= step
